using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using IGlobalist.Cms.Common;
using System.Collections.Generic;
using IGlobalist.Cms.Model;
using IGlobalist.Cms.Bll;

namespace IGlobalist.Cms.Admin
{
    public partial class ProductManegement : AdminBasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                IList<ICmsClass> classList = ClassController.GetClassListByClassTypeID((short)CmsObjectType.Product);
                Session[SessionVariable.Clazz.CurrentID] = null;
                if (classList.Count > 0)
                {
                    ucClassList.DataSource = classList;                    
                    ucClassList.DataBind();                    
                    ucActionBar.ObjectTypeCurrent = CmsObjectType.Content;
                    ucActionBarBottom.ObjectTypeCurrent = CmsObjectType.Content;
                }                
            }
            try
            {

                
                ucActionBar.SaveButtonClick += ucProductAddEdit.DoSaveContent;
                ucActionBarBottom.SaveButtonClick += ucProductAddEdit.DoSaveContent;
                ucProductAddEdit.SaveContent += ucProductAddEdit.DoHidden;
                ucProductAddEdit.SaveContent += ucProductListSummary.DoShow;

                ucProductAddEdit.SaveContent += ucActionBar.DoViewClick;
                ucProductAddEdit.SaveContent += ucActionBarBottom.DoViewClick;

                ucActionBar.NewButtonClick += ucProductAddEdit.DoNewContent;
                ucActionBar.NewButtonClick += ucProductAddEdit.DoShow;
                ucActionBar.NewButtonClick += ucProductListSummary.DoHidden;
                ucActionBar.NewButtonClick  +=HiddenInfo;
                ucActionBar.NewButtonClick += ucProductViewDetail.DoHidden;
                ucActionBarBottom.NewButtonClick += ucProductAddEdit.DoNewContent;
                ucActionBarBottom.NewButtonClick += ucProductAddEdit.DoShow;
                ucActionBarBottom.NewButtonClick += ucProductListSummary.DoHidden;
                ucActionBarBottom.NewButtonClick += ucProductViewDetail.DoHidden;
                ucActionBarBottom.NewButtonClick +=HiddenInfo;
                ucActionBarBottom.NewButtonClick += ucActionBar.DoEditClassClick;
                ucActionBar.NewButtonClick += ucActionBarBottom.DoEditClassClick;
                ucActionBarBottom.NewButtonClick += ucActionBarBottom.DoEditClassClick;
                ucActionBar.NewButtonClick += ucActionBar.DoEditClassClick;

                //ucActionBar.SendApproverContentButtonClick += ucProductAddEdit.DoSendApproverContent;
                //ucActionBar.SendAuthorContentButtonClick += ucProductAddEdit.DoSendAuthorContent;
                //ucActionBar.SendEditContentButtonClick += ucProductAddEdit.DoSendEditContent;

                ucProductListSummary.EditContent += ucProductAddEdit.DoBindContent;
                ucProductListSummary.EditContent += ucProductAddEdit.DoShow;
                ucProductListSummary.EditContent += ucProductListSummary.DoHidden;
                ucProductListSummary.EditContent += ucActionBar.DoEditClassClick;
                ucProductListSummary.EditContent += ucActionBarBottom.DoEditClassClick;
                ucProductListSummary.EditContent += ucProductViewDetail.DoHidden;

                ucClassList.TreeNodeClick += ucProductListSummary.DoBindContent;
                ucClassList.TreeNodeClick += ucProductListSummary.DoShow;
                ucClassList.TreeNodeClick += ucProductAddEdit.DoHidden;
                ucClassList.TreeNodeClick += ucActionBar.DoViewClick;
                ucClassList.TreeNodeClick += ucActionBarBottom.DoViewClick;

                ucClassList.TreeNodeClick += ucProductViewDetail.DoHidden;
                ucClassList.TreeNodeClick += HiddenInfo;
                ucProductListSummary.ViewProductDetail += ucProductViewDetail.DoBind;
                ucProductListSummary.ViewProductDetail += ucProductViewDetail.Doshow;
                ucProductListSummary.ViewProductDetail += ucProductListSummary.DoHidden;
                ucProductListSummary.ViewProductDetail += ucProductAddEdit.DoHidden;
                ucProductListSummary.ViewProductDetail += HiddenInfo;
                ucProductListSummary.ViewProductDetail += ucActionBar.DoViewClick;
                ucProductListSummary.ViewProductDetail += ucActionBarBottom.DoViewClick;


                ucProductViewDetail.EventReturnProductListSummary += ucProductListSummary.DoShow;
                ucProductViewDetail.EventReturnProductListSummary += ucProductViewDetail.DoHidden;
                ucProductViewDetail.EventImageEdit += ucActionBar.DoViewClick;
                ucProductViewDetail.EventImageEdit += ucActionBarBottom.DoViewClick;
                ucProductViewDetail.EventImageEdit += ucProductAddEdit.DoBindContentByProductDetail;
                ucProductViewDetail.EventImageEdit += ucProductAddEdit.DoShow;
                ucProductViewDetail.EventImageEdit += ucProductViewDetail.DoHidden;

            }
            catch (Exception ex)
            {
                Logger.Error("[[Content]]", ex);
            }            
        }

        public void HiddenInfo(object sender, EventArgs e)
        {
            pnlInfo.Visible = false;
        }

    }
}
